package com.yubest.demo;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Slf4j
@SpringBootApplication
public class DemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }

    @Component
    public class MyCommandLineRunner implements CommandLineRunner {
        @Override
        public void run(String... args) throws Exception {
            System.out.println("我来自：CommandLineRunner");
        }
    }

    @Component
    public class MyApplicationRunner implements ApplicationRunner {

        @Override
        public void run(ApplicationArguments args) throws Exception {
            System.out.println("我来自：ApplicationRunner");
        }
    }

    @Configuration
    public class MyPostConstruct {
        @PostConstruct
        public void init() {
            System.out.println("我来自：PostConstruct");
        }
    }

    @Configuration
    public class MyEventListener {
        @EventListener
        public void init(ContextRefreshedEvent event) {
            System.out.println("我来自：EventListener");
        }
    }

}
